<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "creditdetail".
 *
 * @property int $id
 * @property string $username
 * @property int $credit
 * @property int $inblacklist
 */
class Creditdetail extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'creditdetail';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'username'], 'required'],
            [['id', 'credit'], 'integer'],
			[['id', 'credit', 'inblacklist'], 'integer'],
            [['username'], 'string', 'max' => 128],
            [['id'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'username' => 'Username',
            'credit' => 'Credit',
			'inblacklist' => 'Inblacklist',
        ];
    }
    public static function findRecentCreditdetails($limit=10)
    {
    	return Creditdetail::find()->where(['inblacklist'=>0])->orderBy('credit DESC')
    	->limit($limit)->all();
    } 	
}
